﻿//////////////////////////////////////////////////////////////////////////////
//
//  Copyright © 1998-2024 Glodon Company Limited.  All rights reserved.
//
//  Use of this software is subject to the terms of the Glodon license
//  agreement provided at the time of installation or download, or which
//  otherwise accompanies this software in either electronic or hard copy form.  
//
//////////////////////////////////////////////////////////////////////////////


#pragma once
#include "GcmpModelInterface.h"
#include "IElement.h"

namespace gcmp
{
    class IDocument;
    class UniIdentity;
    class IUnitDimension;

    /// \brief 单位量纲定义库
    class GCMP_MODEL_INTERFACE_EXPORT IUnitsLibrary : public IElement
    {
        DEFINE_CAST_DERIVED(gcmp::IUnitsLibrary, gcmp::IElement);
    public:
        /// \brief 析构函数
        virtual ~IUnitsLibrary() {}

        /// \brief 获取当前文档的单位量纲定义库
        ///
        /// \param pDocument 文档指针
        /// \return 单位量纲定义库
        static IUnitsLibrary* Get(const IDocument* pDocument);

        /// \brief 获取对应单位类型的量纲
        ///
        /// \param unitTypeId 单位类型
        /// \return 单位量纲
        virtual const IUnitDimension* GetUnitDimension(const UniIdentity& unitTypeId) const = 0;

        /// \brief 设置对应单位类型的量纲
        ///
        /// \param unitTypeId 单位类型
        /// \param oUnitDimension 单位量纲
        virtual void SetUnitDimension(const UniIdentity& unitTypeId, OwnerPtr<IUnitDimension> oUnitDimension) = 0;
    };
}

